#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: extract_infomation.py
# @time: 2021/3/26 17:23
# @desc:
from utils.utils import *
from utils.mongo_tools import retrieve_one_mongo_standard_part_value
from views.configs import *


def extract_standard_part_json(json_path: str) -> dict:
    """

    :param json_path: 03类型的数据路径加文件名
    :return:
    """
    temp_json = read_json(json_path)
    category_list = [i["category"] for i in temp_json["elements"]]
    result_dict = {}
    for i in category_list:
        temp_result = retrieve_one_mongo_standard_part_value(
            category=i,
            database_name=MONGO_DATABASE_NAME,
            collection_name=STANDARD_PART_COLLECTION,
        )
        if len(temp_result) != 0:
            result_dict[i] = temp_result[0]
    return result_dict
